/*************************************************************************
	> File Name: 013.P1910.L国的战斗之间谍.cpp
	> Author: Maureen 
	> Mail: Maureen@qq.com 
	> Created Time: 二  6/29 15:18:22 2021
 ************************************************************************/

#include <iostream>
using namespace std;

int n, m, x, a[105], b[105], c[105], dp[1005][1005];

int main() {
    cin >> n >> m >> x;
    for (int i = 1; i <= n; i++) cin >> a[i] >> b[i] >> c[i];

    for (int i = 1; i <= n; i++) {
        for (int j = m; j >= b[i]; j--) {
            for (int k = x; k >= c[i]; k--) {
                dp[j][k] = max(dp[j][k], dp[j - b[i]][k - c[i]] + a[i]);
            }
        }
    }
    cout << dp[m][x] << endl;

    return 0;
}
